import {post,get,postQS,getJson,getJson2} from '@/until/request.js'
import store from '@/store'

export function getActivityName(){
	return store.state.activityName
}
export function getActivityType(){
	return store.state.activityType
}

//防止url 不携带参数
const  typePlugin = {
	scratchcard:{
		type:'guess',
		plugin:'scratchcard'
	},
	wheel:{
		type:'guess',
		plugin:'scratchcard'
	},
	relay:{
		type:'guess',
		plugin:'scratchcard'
	},
	worldGuess:{
		type:'sports',
		plugin:'sports'
	},
	scratchcard:{
		type:'answer',
		plugin:'answer'
	},
}

//微信借权
export function getWechatAuth(data={}){
	return get('/user/wx-auth-url',data)
}
//微信登录信息
export function loginWx(data={}){
	return get('/user/wx-auth-login',data)
}

//微信头像图片替换
export function getQianFanImage(data){
	return post('/communal/index/image-convert',data)
}

//app login 查验是否绑定微信 （app强制解析这个接口）
export function appLogin(data={}){
	return get('/user/app-login',data)
}

//小程序 login 同步用户登录到活动 插件状态任何解析结果401 都要刷一次这个接口
export function miniLogin(data={}){
	return post('/user/mp-auth-login',data)
}

//获取用户信息
export function getUserInfo(data={}){
	return get('/user/index',data)
}
//竞猜活动信息
export function ActivityInfo(data={},typename=null,pluginname=null){
	let name =pluginname || getActivityName()
	let type =typename || getActivityType()
	return get('/'+type+'/'+name+'/index',data)
}

//获取当前登录，活动参与人数
export function getIfCanRelay(data={},pluginname=null){
	let name = pluginname || getActivityName()
	return get('/guess/'+name+'/finish',data)
}

//获取刮奖次数
export function chance(data={},typename=null,pluginname=null){
	let name =pluginname || getActivityName()
	let type =typename || getActivityType()
	return get('/'+type+'/'+name+'/chance',data)
}
//获取动态文本
export function  activityText(data={},typename=null,pluginname=null){
	let name =pluginname || getActivityName()
	let type =typename || getActivityType()
	return get('/'+type+'/'+name+'/data',data)
}

//刮奖接口
export function getGuess(data={},pluginname=null){
	let name = pluginname || getActivityName()
	if(data.actid){
		return post('/guess/'+name+'/guess?actid='+data.actid,{})
	}
	return post('/guess/'+name+'/guess',data)
}
//奖品列表
export function prizeList(data={},pluginname="guess") {
	if(data.actid){
		return get('/'+pluginname+'/prize/index?actid='+data.actid,data)
	}
	return get('/'+pluginname+'/prize/index', data)
}
//奖品详情
export function prizeInfo(data={},pluginname='guess') {
	return get('/'+pluginname+'/prize/info', data)
}
//获取奖品加密 码
export function verifier(data={},pluginname='guess') {
	return get('/'+pluginname+'/prize/verifier', data)
}
//虚拟红包兑换
export function virtualVerifier(data={},pluginname='guess') {
	return get('/'+pluginname+'/prize/virtual-verifier', data)
}
//任务列表
export function taskList(data={}) {
	return get('/task/task/task-list', data)
}
//查询任务完成条件
export function taskConditions(data={}){
	return get('/task/task/task-conditions',data)
}
//完成任务
export function taskFinished(data={}) {
	return post('/task/task/task-finished', data)
}

//邀请 --- 助力接口---获取相关信息
export function taskInvite(data={}) {
	return get('/task/task/invite-code', data)
}
//微信登录
export function loginByCode(data={}){
	return post('/v4_0/mini/login-by-code',getJson2(data))
}
//公共参数
export function index(data={}){
	return get('/communal/index/index',data)
}
//微信分享
export function wechatShare(data){
	return get('/communal/index/wechat-share',data)
}

/*接力获取人数poster*/
export function getRelayNumber(data,pluginname=null){
	let name = pluginname || getActivityName()

	return post('/guess/'+name+'/relay?actid='+data.actid, data)
}

/*竞猜*/

//获取竞猜是否有未兑奖
export function getIfHasReward(data={}){
	return get('/sports/sports/finish',data)
}

//竞猜活动信息
export function guessSportsInfo(data={}){
	return get('/sports/sports/index',data)
}

//获取动态文本
export function  guessSportsText(data={},typename='sports',pluginname='sports'){
	return get('/'+typename+'/'+pluginname+'/data',data)
}

/*获取赛事列表*/
export function  guessSportsList(data={}){
	return get('/sports/sports/race',data)
}

/*获取赛事详情*/
export function  guessSportsDetail(data={}){
	return get('/sports/sports/race-view',data)
}

/*投注赛事*/
export function betSports(data={}){
	return get('/sports/sports/bet',data)
}

/*获取竞猜卡张数*/
export function  getSportsCard(data={},typename=null,pluginname=null){
	let name = pluginname || getActivityName()
	let type = typename || getActivityType()
	return get('/'+type+'/'+name+'/chance',data)
}


/*竞猜记录*/
export function  mineSportsRecord(data={}){
	return get('/sports/record/record',data)
}

/*中奖记录*/
export function  mineWinning(data={}){
	return get('/sports/record/winning',data)
}

/*领红包*/
export function getReward(data={}){
	return get('/' + 'sports/record/receive-cash?rid='+data.rid,data)
}
//排行榜
export function getRank(data={},typename='sports',pluginname='sports'){
	if(pluginname=="sports"){
		return get('/sports/record/ranking',data)
	}else{
		return get('/'+typename+'/'+pluginname+'/ranking',data)
	}
	
}

//开始答题
export function startAnswer(data){
	return post('/answer/answer/answer?actid='+data.actid+'&plugin='+data.plugin,data)
}
//答题抽奖
export function getAnswerPrize(data,pluginType='answer'){
	return post('/'+pluginType+'/'+pluginType+'/lottery?actid='+data.actid+'&plugin='+data.plugin,data)
}
//投訴
export function sendComplain(data){
	return post('/communal/complaint/create?actid='+data.actid+'&plugin='+data.plugin,data)
}


/*sport 实物奖*/
export function getSportsPrizeInfo(data={}){
	return get('/sports/record/prize-info',data)
}

/*获取皮肤参数*/

export function getSkinType(data={}){
	return get('/sports/sports/skin',data)
}

//集字信息
export function collectWord(data={},typename=null,pluginname=null){
	let name =pluginname || getActivityName()
	let type =typename || getActivityType()
	return get('/'+type+'/'+name+'/words',data)
}
//集字抽字
export function collectLottery(data={},typename=null,pluginname=null){
	let name =pluginname || getActivityName()
	let type =typename || getActivityType()
	return post('/'+type+'/'+name+'/lottery?actid='+data.actid,data)
}

export function getUserPhone(data){
	return get('/actuser/index/user-phone',data)
}
export function setUserPhone(data){
	return post('/actuser/index/sync-user-phone',data)
}
//投票作品列表
export function getVoteWork(data){
	return get('/vote/vote/works',data)
}
//投票作品详情
export function getVoteWorkInfo(data){
	return get('/vote/vote/works-info',data)
}

//投票分组列表
export function getVoteGroup(data){
	return get('/vote/vote/group',data)
}
//投票分组列表
export function getVoteUserWorks(data){
	return get('/vote/vote/user-works',data)
}
//投票报名字段
export function getVotePrereg(data){
	return get('/vote/vote/pre-reg',data)
}
//投票报名
export function postVotePrereg(data){
	return post('/vote/vote/reg?actid='+data.actid,data)
}
//投票评论列表
export function getVoteUserWorksComment(data){
	return get('/vote/vote/works-comment',data)
}

//投票个人作品
export function getVoteUserWorksList(data){
	return get('/vote/vote/user-works',data)
}

//投票个人作品详情
export function getVoteUserWorksDetail(data){
	return get('/vote/vote/reg-works',data)
}
//投票评论列表
export function getVoteComment(data){
	return get('/vote/vote/works-comment',data)
}
//投票评论列表
export function createVoteComment(data){
	return post('/vote/vote/comment?actid='+data.actid+'&plugin='+data.plugin,data)
}
//投票-投票作品
export function voteWork(data){
	return post('/vote/vote/vote?actid='+data.actid+'&plugin='+data.plugin,data)
}
//投票-投票作品抽獎
export function workLottery(data,type,plugin){
	return post('/'+type+'/'+plugin+'/lottery?actid='+data.actid+'&plugin='+data.plugin,data)
}
//投票-礼物
export function getVoteGift(data){
	return get('/vote/vote/gift',data)
}
//投票-礼物购买
export function buyVoteGift(data){
	return post('/vote/vote/buy-gift?actid='+data.actid+'&plugin='+data.plugin,data)
}
//投票-预发布字段
export function getVotePreAdd(data){
	return get('/vote/vote/pre-add',data)
}
export function getVotGiftRecord(data){
	return get('/vote/vote/gift-record',data)
}
//腾讯验证码
export function getTecentCheck(data,type,plugin){
	return get('/'+type+'/'+plugin+'/tencent-check',data)
}

//求签
export function drawlots(data){
	return post('/drawlots/drawlots/draw?actid='+data.actid+'&plugin='+data.plugin,data)
}
//求签列表
export function getLotsList(data){
	return get('/drawlots/drawlots/user-lots',data)
}
//翻牌抽奖
export function getCardsPrize(data){
	return post('/guess/cards/guess?actid='+data.id,data)
}
//红包雨开始
export function redpkgStart(data){
	return post('/redpkg/redpkg/start?actid='+data.actid+'&plugin=redpkg',data)
}

//红包抽奖
export function redpkgFinish(data){
	return post('/redpkg/redpkg/finish?actid='+data.actid+'&plugin=redpkg',data)
}


